﻿@using EC.Entity.Enum;
@{
    Layout = "~/Views/Shared/_Dialog.cshtml";
}
@section HeadCss{
    <link href="@Url.Content("~/lib/select2/select2.min.css")" rel="stylesheet" />
}
@section headScripts{
    <script type="text/javascript" src="@Url.Content("~/lib/select2/select2.min.js")"></script>
}
@model EC.Entity.Response.Merchant.MerchantResponse
<section class="container-fluid" style="background-color: white;">
    <form class="form-horizontal m15_t" id="form">
        <div class="tab-content">
            <input type="hidden" id="Id" name="Id" value="@(Model.Id)">
            <div class="tab-pane fade in active" id="home">
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>名称：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="name" maxlength="40" value="@(Model.Name)" autocomplete="off" placeholder="长度必须介于 2 和 40 之间">
                    </div>
                </div>

                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>代付费率(%)：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="paymentRate" maxlength="40" value="@(Model.PaymentRate)" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>收款费率(%)：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="depositRate" maxlength="40" value="@(Model.DepositRate)" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>宝转卡费率(%)：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="depositAliPayRate" maxlength="40" value="@(Model.DepositAliPayRate)" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>单笔支付费：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="paymentSingle" maxlength="40" value="@(Model.PaymentSingle)" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>结算手续费：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="settleSingle" maxlength="40" value="@(Model.SettleSingle)" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">付款通知：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="paymentNotifyUrl" maxlength="500" value="@(Model.PaymentNotifyUrl)" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">存款通知：</label>
                    <div class="wd300">
                        <input class="form-control" type="text" name="depositNotifyUrl" maxlength="500" value="@(Model.DepositNotifyUrl)" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>类型：</label>
                    <div class="wd300">
                        <select class="form-control gettext" name="type">
                            <option value="">请选择</option>
                            @{
                                if (Model.Type == 10)
                                {
                                    <option value="10" selected>代理</option>
                                }
                                else
                                {
                                    <option value="10">代理</option>
                                }
                                if (Model.Type == 20)
                                {
                                    <option value="20" selected>商户</option>
                                }
                                else
                                {
                                    <option value="0">系统管理员</option>
                                }
                            }


                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>状态：</label>
                    <div class="wd300">
                        <label class="m10_r">
                            <input type="radio" name="status" value="@((int)MerchantStatus.启用)" @(Model.Status.Equals((int)MerchantStatus.启用) ? "checked" : "")> 启用
                        </label>
                        <label>
                            <input type="radio" name="status" value="@((int)MerchantStatus.禁用)" @(Model.Status.Equals((int)MerchantStatus.禁用) ? "checked" : "")> 禁用
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>
@section footerScript{
    <script type="text/javascript">

        function save() {

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            var data = $("#form").serializeJSON();
            //状态
            //data.status = $("input[name='status'][checked]").val();

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Merchant/Save",
                data: data,
                success: function (res) {
                    if (res.success) {
                        cover.Remove();
                        FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

        }
    </script>
}